1. Field of the Invention
This invention relates to a microcomputer of a one-chip type for controlling external devices, and more particularly to a function for detecting microcomputer processing a failure of externally connected devices.
2. Description of Related Art
One-chip microcomputers are widely used in control of automobiles, electric household appliances, etc. When using the one-chip microcomputer for control in a field where high reliability is required, detection of a failure is very important, and it is desired that a failure be detected and corrected by the microcomputer as promptly as possible. In the control of an automobile automatic transmission, if an electromagnetic valve, which is one of the external devices, should fail to operate normally due to an abnormality such as disconnection of a wire, control of the hydraulic system is disabled, and the transmission gear may malfunction or break down. Therefore, when a microcomputer is used in this control, a failure detection function such as that referred to above is particularly important.
FIG. 1 is a schematic block diagram showing the structure of a failure detecting system of a conventional microcomputer used in control of an electromagnetic valve. In this block diagram, numeral 1 denotes a one-chip microcomputer for controlling the automatic transmission of an automobile, and this microcomputer 1 comprises a PS signal generator 3 which generates and delivers a pulse modulation signal PS for driving an electromagnetic valve 2. The electromagnetic valve 2 is intended to control the automatic transmission by regulating the feed direction of oil pressure. The electromagnetic valve 2 comprises an emitter-grounded npn transistor 22 which receives, as an input, the pulse modulation signal PS at its base and turns on and off the collector current accordingly. Valve 2 also includes an excitation coil 21 of which one end is connected to a power source and the other end is connected to the collector. The collector current is given to a level detecting circuit 6 of the microcomputer 1 as a monitor signal MS for showing the state of the electromagnetic valve 2 through an inverter 23. The level detecting circuit 6 checks the level of the inputted monitor signal MS, and detects trouble in the electromagnetive valve 2.
The operation of the conventional microcomputer is described below. In order to operate the electromagnetic valve 2, the microcomputer 1 gives a pulse modulation signal PS to the electromagnetic valve 2. When the electromagnetic valve 2 functions normally, a monitor signal MS is actuated, and the microcomputer 1 detects a failure by checking the level of the monitor signal MS.
The above-described process of detecting a failure is shown in the timing chart of FIG. 2. In this chart, the pulse modulation signal PS, monitor signal MS, and level detection timing are shown in timed relation. As stated above, the failure of the electromagnetic valve 2 is detected by investigating the level of the monitor signal MS, but the monitor signal MS is often delayed at its changing point as indicated by 4a in FIG. 2, therefore, if the level of the monitor signal MS is judged at the changing point of the pulse modulation signal PS, the result tends to be insecure. Accordingly, hitherto, either the monitor timing system A or B as shown in the chart has been employed.
In the monitor timing system A, the monitor action is delayed by a waiting time .tau. by software or by exclusive hardware, from the changing point of the pulse modulation signal PS until the stabilization of the monitor signal MS. As a result of the monitoring, the failure is detected by seeing whether or not the level is different from the result of the previous investigation.
In the monitor timing system B, the monitor signal MS is investigated at every specific time interval, and it is determined if a result of a different level is obtained after several monitoring times.
Microcomputer controls tend to be much higher in speed recently, and the pulse modulation signal PS shown in FIG. 2 is also increased in speed in order to raise controlling accuracy. For example, in the case of a pulse modulation signal PS with a shorter pulse width than the waiting time t as shown in FIG. 3, it is not possible according to the conventional monitor timing system A to monitor at the optimum timing if the monitor signal MS is monitored by the same conventional waiting time .tau.. Therefore, normal operation cannot be detected. When the waiting time .tau. is shortened, although a detectable timing is obtained, the instability time and pulse width vary due to the delay of the monitor signal MS, etc. in every external electromagnetic valve 2, and therefore the waiting time .tau. is required to be variable. In the circumstances above, if it is attempted to detect a failure at high speeds by the conventional method, the program becomes complicated when monitor timing is generated by the software, rendering the load heavier. Meanwhile, when the monitor timing is realized by hardware, it leads to an increase in the number of circuits. Even in the complete absence of the instability time, if the pulse width becomes shorter, the timing for executing monitoring of the monitor signal MS is limited, and the load for executing monitoring is increased. The same holds true with the case of the monitor timing system B. The main routine becomes lengthy, due to the increase in load of the software, and the time interval of monitorings of the monitor signal MS tends to be longer. It is hence hard to monitor the pulse width which tends to be shorter.